"use strict";
exports.__esModule = true;
var path = require("path");
var fse = require("fs-extra");
var config = require("./store.config.js");
var albumPath = path.resolve(__dirname, "..", config.album.contentDir);
var deployPath = path.resolve(__dirname, "../deploy");
fse.ensureDir(deployPath);
fse.emptyDirSync(deployPath);
fse.readdirSync(albumPath, "utf8").forEach(function (dir) {
    var stat = fse.statSync(path.resolve(albumPath, dir));
    if (stat.isDirectory()) {
        var content = fse.readdirSync(path.resolve(albumPath, dir), "utf8");
        var albumConfig = require(path.resolve(albumPath, dir, config.album.configFile));
        var storage = albumConfig.storage || "$_NO_NAME_ERROR";
        var storageName = storage.substr(storage.lastIndexOf("/") + 1);
        var copyPath_1 = path.resolve(deployPath, storageName, albumConfig.name);
        fse.ensureDir(copyPath_1);
        content.forEach(function (file) {
            if (file !== config.album.configFile) {
                fse.copySync(path.resolve(albumPath, dir, file), path.resolve(copyPath_1, file));
            }
        });
    }
});
